import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:top_foundation/top_foundation.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class GroupedListPage extends GetView<GroupedListController> {
  const GroupedListPage({Key? key}) : super(key: key);

  // 主视图
  Widget _buildView() {
    return GroupedListView(
      sectionCount: 5,
      itemCount: (section) {
        return 5;
      },
      sectionHeight: (section) {
        return 40.r;
      },
      sectionBuilder: (context, idx) {
        return Container(
          height: 40.r,
          color: Colors.white,
          alignment: Alignment.centerLeft,
          child: Text(idx.toString()),
        );
      },
      itemBuilder: (section, item) {
        return Container(
          height: 80.r,
          color: Colors.blue,
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<GroupedListController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("grouped_list")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
